﻿<%@ Page Language="C#" MasterPageFile="~/Layouts/List.Master" AutoEventWireup="true"
    Inherits="HHMMS.UI.Modules.Common.AttachmentInfoList" Title="图片资源管理" CodeBehind="AttachmentInfoList.aspx.cs" %>

<asp:Content ContentPlaceHolderID="head" ID="idFormTitle" runat="server">
    <!-- title -->
    <link type="text/css" rel="Stylesheet" href="../../Scripts/Uploadify/uploadify.css" />
    <web:Script ID="uploadify" runat="server" src="~/Scripts/Uploadify/jquery.uploadify-3.1.min.js" />
</asp:Content>

<asp:Content ID="idContent" ContentPlaceHolderID="Content" runat="Server">   
    <!-- 搜索框 -->
    <div class="search" style="margin-top:2px;">     
        <web:search ID="GridSearch" GridViewId="SmartGridView1" runat="server">            
            <SearchConditionTemplate>                                       
                <table cellpadding="0" cellspacing="0" width="95%">
                  <tr>
						<th>
							文件名称：
						</th>
						<td>
							<asp:TextBox ID="tbFileName" Name="FileName" runat="server" ></asp:TextBox>
						</td>                                       
						<th>
							上传日期：
						</th>
						<td>
							<web:DatePicker ID="dpCreateDate" Name="StartCreateDate" runat="server" Width="80px"/>
                            到
                            <web:DatePicker ID="DatePicker1" Name="EndCreateDate" runat="server" Width="80px"/>
						</td>                                       
					</tr>
                </table>
            </SearchConditionTemplate>                      
        </web:search>
    </div>

    <div class="datalist">
        <!-- 标题头 -->
        <h2 style="height:30px;">附件信息列表</h2>
        <!-- 工具栏 -->
        <asp:LinkButton ID="lbtnRefresh" runat="server" OnClick="lbtnRefresh_Click" style="display:none;">刷新</asp:LinkButton>
        <div class="toolbar"  style="height:30px; text-align:right;">
            <div style=" width:84px; height:25px; float:right;">
                <input id="fileUpload" type="file" />
            </div>
        </div>
        <div class="datagrid"  style="clear:left;">    
            <!--------------------------- List Area --------------------------->
            <web:SmartGridView ID="SmartGridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="OnRowDataBound"
                Width="100%" DataKeyNames="ID" DataSourceID="SmartDataSource1" PageSize="10">
                <Columns>   
                    <asp:TemplateField HeaderText="文件名称">
                        <ItemTemplate>
                            <a href='<%#Eval("FileUrl") %>' target="_self" title="点击下载文件"><%#Eval("FileName") %></a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="文件大小" ItemStyle-HorizontalAlign = "Center">
                        <ItemTemplate>
                            <asp:Label ID="lblFileSize" runat="server"></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CreatorName" HeaderText="创建人" SortExpression="CreatorName" ItemStyle-HorizontalAlign = "Center"  />
                    <asp:BoundField DataField="CreateDate" HeaderText="上传日期" SortExpression="CreateDate" ItemStyle-HorizontalAlign = "Center" DataFormatString="{0:yyyy-MM-dd HH:mm}" />
                    <asp:TemplateField HeaderText="操作">
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderStyle Wrap="False" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <table width="46px">
                                <tr>                                    
                                    <td style="border: 0px solid #fff;">
                                        <asp:ImageButton runat="server" ToolTip="删除" ImageUrl="~/images/com/dg_del.gif" _ID='<%#Eval("ID")%>'
                                            CausesValidation="False" OnClientClick="return confirm('您确认要删除吗?')" OnClick="DeleteAttachmentInfo">
                                        </asp:ImageButton>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings />
                <EditRowStyle HorizontalAlign="Center" />
            </web:SmartGridView>
    
            <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="Common.AttachmentInfo.List" SelectCountCommand="Common.AttachmentInfo.List.Count"
                    DefaultSortExpression="ID DESC" SelectCommandAutoPageWrap="true">
            </web:SmartSqlDataSource>
        </div>
    </div>

    <script type="text/javascript">
        $(function () {
            var typeID = '<%=Request.QueryString["typeID"] %>';
            var dataKey = '<%=Request.QueryString["dataKey"] %>';
            var refresh = function(){
                <%=this.ClientScript.GetPostBackEventReference(this.lbtnRefresh, null) %>;
            }
            
            //绑定上传控件
            $("#fileUpload").uploadify({
                'buttonImage': Global.contextPath + '/Images/addfile.jpg',
                'uploader': Global.contextPath + '/upload.ashx',
                'width': 84,
                'height': 25,
                'buttonText': '',
                'formData': { attachTypeID: typeID, Mark1: dataKey },
                'swf': Global.contextPath + '/Scripts/uploadify/uploadify.swf',
                'multi': false,
                'fileSizeLimit': '10MB',
                'fileTypeExts': '*.jpg;*.jpeg;*.bmp;*.gif;*.png',
                'fileTypeDesc': '图片文件',
                'successTimeout': 60000, //等待服务器响应最长时间
                'onUploadSuccess': function (file, data, response) {
                    //刷新页面
                    refresh();
                },
                'onFallback': function () {
                    alert('没有检测到flash插件，请先下载安装后刷新页面再重试！');
                }
            });
        });
        
        function openForm(_this, action) {
            var url;

            // FormViewMode : Insert/Edit/ReadOnly
            var params = {FormViewMode: action }
            if (action == "Insert") {
                url = "AttachmentInfoEdit.aspx";
                params.title = "附件信息新增";
            } else if (action == "Edit") {
                url = "AttachmentInfoEdit.aspx";
                params.title = "附件信息编辑";
                params.Id = _this.attributes["_ID"].value;
            }

            var returnValue = showCenterModalDialog(buildUrl(url, params), 620, 500, null);

            return returnValue == "true";
        }       
    </script>

</asp:Content>